home *** CD-ROM | disk | FTP | other *** search
/ Champak 146 / (Vol 146) Jan 07 2012.iso / Games / scuba.swf / scripts / frame_18 / PlaceObject2_195_401 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Text File  |  2012-01-07  |  5KB  |  110 lines

  1. onClipEvent(enterFrame){
  2.    if(status == "active")
  3.    {
  4.       if(this._x >= _root.RIGHT_BOUND)
  5.       {
  6.          if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL)),this._y,true) == true)
  7.          {
  8.             vSideOfImpact = "undetermined";
  9.             vPixelCounter = Number(1);
  10.             while(vSideOfImpact == "undetermined")
  11.             {
  12.                if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL)),Number(this._y + Number(vPixelCounter)),true) == false && Number(this._y + Number(vPixelCounter)) < _root.BOTTOM_BOUND)
  13.                {
  14.                   vSideOfImpact = "top";
  15.                   vPixelOffset = vPixelCounter;
  16.                }
  17.                else if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL)),Number(this._y - Number(vPixelCounter)),true) == false && _root.TOP_BOUND < Number(this._y - Number(vPixelCounter)))
  18.                {
  19.                   vSideOfImpact = "bottom";
  20.                   vPixelOffset = vPixelCounter;
  21.                }
  22.                vPixelCounter++;
  23.             }
  24.             if(vSideOfImpact == "top")
  25.             {
  26.                setProperty(this, _Y, Number(this._y + Number(vPixelOffset)));
  27.             }
  28.             else if(vSideOfImpact == "bottom")
  29.             {
  30.                setProperty(this, _Y, Number(this._y - Number(vPixelOffset)));
  31.             }
  32.          }
  33.       }
  34.       else if(this._x < _root.RIGHT_BOUND)
  35.       {
  36.          vSideOfImpact = "undetermined";
  37.          i = 5;
  38.          while(i < 100 && vSideOfImpact == "undetermined")
  39.          {
  40.             if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL) * i),this._y,true) == true)
  41.             {
  42.                vPixelCounter = Number(1);
  43.                while(vSideOfImpact == "undetermined")
  44.                {
  45.                   vAdjustmentDiv = Number(i);
  46.                   if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL) * i),Number(this._y - Number(vPixelCounter)),true) == true && _root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL) * i),Number(this._y + Number(vPixelCounter)),true) == false)
  47.                   {
  48.                      vSideOfImpact = "top";
  49.                      vPixelOffset = Number(vPixelCounter + Number(this._height * 2));
  50.                   }
  51.                   else if(_root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL) * i),Number(this._y - Number(vPixelCounter)),true) == false && _root.coral.hitTest(Number(this._x - Number(_root.FISH_ACCEL) * i),Number(this._y + Number(vPixelCounter)),true) == true)
  52.                   {
  53.                      vSideOfImpact = "bottom";
  54.                      vPixelOffset = Number(vPixelCounter + Number(this._height * 2));
  55.                   }
  56.                   vPixelCounter++;
  57.                }
  58.                if(vSideOfImpact == "top")
  59.                {
  60.                   if(vSwimmingDir == "straight")
  61.                   {
  62.                      vSwimmingDir = "down";
  63.                      setProperty(this, _Y, this._y + Number(vPixelOffset / vAdjustmentDiv));
  64.                   }
  65.                   else if(vSwimmingDir == "down")
  66.                   {
  67.                      setProperty(this, _Y, this._y + Number(vPixelOffset / vAdjustmentDiv));
  68.                   }
  69.                   else if(vSwimmingDir == "up")
  70.                   {
  71.                      vSwimmingDir = "straight";
  72.                   }
  73.                }
  74.                else if(vSideOfImpact == "bottom")
  75.                {
  76.                   if(vSwimmingDir == "straight")
  77.                   {
  78.                      vSwimmingDir = "up";
  79.                      setProperty(this, _Y, this._y - Number(vPixelOffset / vAdjustmentDiv));
  80.                   }
  81.                   else if(vSwimmingDir == "up")
  82.                   {
  83.                      setProperty(this, _Y, this._y - Number(vPixelOffset / vAdjustmentDiv));
  84.                   }
  85.                   else if(vSwimmingDir == "down")
  86.                   {
  87.                      vSwimmingDir = "straight";
  88.                   }
  89.                }
  90.             }
  91.             else
  92.             {
  93.                vSwimmingDir = "straight";
  94.             }
  95.             i = Number(i + Number(3));
  96.          }
  97.          if(vProdded == false && _root.gProdStatus == "activated" && _root.recruit.prod.hitTest(this) == true)
  98.          {
  99.             vProdded = true;
  100.             this.gotoAndPlay("prodded");
  101.          }
  102.          else if(vAttackedDiver == false && _root.gProdStatus == "not_activated" && _root.recruit.diver.hitTest(this) == true && vProdded == false && Number(Math.abs(Number(Math.abs(this._x) - Math.abs(Number(_root.recruit._x + Number(_root.recruit.diver._x))))) + Math.abs(Number(Math.abs(this._y) - Math.abs(Number(_root.recruit._y + Number(_root.recruit.diver._y)))))) < _root.SAFETY_DIFF)
  103.          {
  104.             vAttackedDiver = true;
  105.             _root.fnCreatureAttack();
  106.          }
  107.       }
  108.    }
  109. }
  110.